﻿<UserControl x:Class="XamlHelpmeet.UI.Editors.DatePickerEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:XamlHelpmeet.UI.Editors"
             xmlns:cvtrs="clr-namespace:XamlHelpmeet.UI.Converters"
             Loaded="DatePickerEditor_Loaded"
             >
    <UserControl.Resources>

        <cvtrs:PropertyTypeNameConverter x:Key="propertyTypeNameConverter" />

        <Style TargetType="{x:Type StackPanel}">
            <Setter Property="Margin" Value="0,10,0,0" />
        </Style>

        <ControlTemplate x:Key="validationTemplate">
            <DockPanel>
                <AdornedElementPlaceholder x:Name="errorAdorner" />
                <TextBlock Margin="2,0,5,0"
                           VerticalAlignment="Center"
                           FontSize="20"
                           Foreground="Red"
                           Text="*"
                           ToolTip="{Binding ElementName=errorAdorner,
                                             Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" />
            </DockPanel>
        </ControlTemplate>

        <Style TargetType="{x:Type TextBox}">
            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource validationTemplate}" />
        </Style>

    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <StackPanel Orientation="Horizontal">
            <TextBlock Width="50" Text="Path" />
            <Grid>
                <TextBox x:Name="txtBindingPath"
                         Width="100"
                         VerticalAlignment="Top" />
                <ComboBox x:Name="cboBindingPath"
                          MinWidth="100"
                          VerticalAlignment="Top"
                          SelectedValuePath="Name"
                          Visibility="Collapsed">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=Name}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </Grid>

        </StackPanel>

    </Grid>
</UserControl>
